//
//  SYS_HttpUtility.m
//  System_App
//
//  Created by 吴健 on 2017/12/1.
//  Copyright © 2017年 czy001. All rights reserved.
//

#import "SYS_HttpUtility.h"

@implementation SYS_HttpUtility

+ (void)getHomeDataRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure{
    NSString *path = [SERVICE_IP stringByAppendingString:@"/jf/adm/sysapp/statistics/home"];
    [NetRequestClass NetRequestPOSTWithRequestURL:path WithParameter:params WithReturnValeuBlock:^(id returnValue) {
        success(returnValue);
        
    } WithErrorCodeBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        failure(failure);
    }];
}

+ (void)getShipmentOrderListRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure{
    NSString *path = [SERVICE_IP stringByAppendingString:@"/jf/adm/sysapp/order/orders"];
    [NetRequestClass NetRequestPOSTWithRequestURL:path WithParameter:params WithReturnValeuBlock:^(id returnValue) {
        success(returnValue);
        
    } WithErrorCodeBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        failure(failure);
    }];
}

+ (void)getOrderInfoRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure{
    NSString *path = [SERVICE_IP stringByAppendingString:@"/jf/adm/sysapp/order/orderInfo"];
    [NetRequestClass NetRequestPOSTWithRequestURL:path WithParameter:params WithReturnValeuBlock:^(id returnValue) {
        success(returnValue);
        
    } WithErrorCodeBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        failure(failure);
    }];
}
    
//门店列表
+ (void)getStoreListRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure
{
    NSString *path = [SERVICE_IP stringByAppendingString:@"/jf/adm/sysapp/user/info/stores"];
    [NetRequestClass NetRequestPOSTWithRequestURL:path WithParameter:params WithReturnValeuBlock:^(id returnValue) {
        success(returnValue);
        
    } WithErrorCodeBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        failure(failure);
    }];
}

//查询门店员工组
+ (void)getStoreEmplyeesListRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure
{
    NSString *path = [SERVICE_IP stringByAppendingString:@"/jf/adm/sysapp/user/info/storeEmps"];
    [NetRequestClass NetRequestPOSTWithRequestURL:path WithParameter:params WithReturnValeuBlock:^(id returnValue) {
        success(returnValue);
        
    } WithErrorCodeBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        failure(failure);
    }];
}

//查询单个员工信息
+ (void)getSingleEmployeInfoRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure
{
    NSString *path = [SERVICE_IP stringByAppendingString:@"/jf/adm/sysapp/user/info/storeEmpInfo"];
    [NetRequestClass NetRequestPOSTWithRequestURL:path WithParameter:params WithReturnValeuBlock:^(id returnValue) {
        success(returnValue);
        
    } WithErrorCodeBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        failure(failure);
    }];
}

//会员列表
+ (void)getMemberListRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure
{
    NSString *path = [SERVICE_IP stringByAppendingString:@"/jf/adm/sysapp/user/info/ownerList"];
    [NetRequestClass NetRequestPOSTWithRequestURL:path WithParameter:params WithReturnValeuBlock:^(id returnValue) {
        success(returnValue);
        
    } WithErrorCodeBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        failure(failure);
    }];
}

//会员信息
+ (void)getMemberInfoRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure
{
    NSString *path = [SERVICE_IP stringByAppendingString:@"/jf/adm/sysapp/user/info/ownerInfo"];
    [NetRequestClass NetRequestPOSTWithRequestURL:path WithParameter:params WithReturnValeuBlock:^(id returnValue) {
        success(returnValue);
        
    } WithErrorCodeBlock:^(id errorCode) {
        
    } WithFailureBlock:^{
        failure(failure);
    }];
}

+ (void)getDeliverGoodsRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure{
    NSString *path = [SERVICE_IP stringByAppendingPathComponent:@"/jf/adm/sysapp/order/deliverGoods"];
    //1.管理器
    
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    
    session.responseSerializer = [AFHTTPResponseSerializer serializer];
    //    manager.requestSerializer.timeoutInterval = 5.0;
    // 加上这行代码，https ssl 验证。
    
    AFSecurityPolicy *securityPolicy = [AFNetWorking_policy customSecurityPolicy];
    //     allowInvalidCertificates 是否允许无效证书（也就是自建的证书），默认为NO
    //     如果是需要验证自建证书，需要设置为YES
    securityPolicy.allowInvalidCertificates = YES;
    session.securityPolicy = securityPolicy;
    
    [session POST:path parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSError *error=nil;
        NSDictionary *dataDic = [NSJSONSerialization JSONObjectWithData:responseObject
                                                                options:NSJSONReadingMutableLeaves
                                                                  error:&error];
        success(dataDic); //自动返回主线程
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
    
}

+ (void)getShipOrderRequest:(NSDictionary *)params success:(ReturnValueBlock)success failure:(FailureBlock)failure{
    NSString *path = [SERVICE_IP stringByAppendingPathComponent:@"/jf/adm/sysapp/order/shipOrder"];
    //1.管理器
    
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    
    session.responseSerializer = [AFHTTPResponseSerializer serializer];
    //    manager.requestSerializer.timeoutInterval = 5.0;
    // 加上这行代码，https ssl 验证。
    
    AFSecurityPolicy *securityPolicy = [AFNetWorking_policy customSecurityPolicy];
    //     allowInvalidCertificates 是否允许无效证书（也就是自建的证书），默认为NO
    //     如果是需要验证自建证书，需要设置为YES
    securityPolicy.allowInvalidCertificates = YES;
    session.securityPolicy = securityPolicy;
    
    [session POST:path parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSError *error=nil;
        NSDictionary *dataDic = [NSJSONSerialization JSONObjectWithData:responseObject
                                                                options:NSJSONReadingMutableLeaves
                                                                  error:&error];
        success(dataDic); //自动返回主线程
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        failure(error);
    }];
}

@end
